<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>_入库单管理</title>
	
	  <script type="text/javascript" language="javascript">
	  
	 	$(function() {
		    $("#inputForm").validate(); //为inputForm注册validate函数
	    });
	  
	    //检查图片格式
        function checkPic() {
            var picPath = document.getElementById("picPath").value;
            var type = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length).toLowerCase();
            if (type != "jpg" && type != "bmp" && type != "gif" && type != "png") {
                alert("请上传正确的图片格式");
                return false;
            }
            return true;
        }
        
        //图片预览
        function previewImage(upload) {
            if (checkPic()) {
                try {
                    var imgPath;      //图片路径
                    var Browser_Agent = navigator.userAgent;
                    
                    if (Browser_Agent.indexOf("Firefox") != -1) {   //火狐浏览器
                        imgPath = window.URL.createObjectURL(upload.files[0]);
                        $("#preview_div").html( "<img id='imgPreview' src='"+imgPath+"' style='width:552px;height:200px;cursor:crosshair;' />" );
                    } else {                      //IE浏览器
                        var Preview = document.getElementById("preview_div");
                        Preview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = upload.value;
                        Preview.style.width = 552;
                        Preview.style.height = 200;
                        
                    }
                } catch (e) {
                    alert("服务器繁忙，请稍后重试！");
                }
            }
        }
        
        //重设表单
        function formReset(){
          $("input[type=reset]").trigger("click");
          $("#preview_div").html( "<img id='imgPreview' src='${ctx}/static/images/noexist.jpg' style='width:552px;height:200px;' />" );
        }
        
        
    </script>
	
</head>

<body>
    <c:if test="${not empty message}">
		<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
	</c:if>
	
   <div class="tabbable">
	  	<ul class="nav nav-tabs">
			<li class="${tab1}">
				<a href="#tab1" data-toggle="tab" >入库登记<span id="fold"></span> </a>
			</li>
			<li class="${tab2}">
				<a href="#tab2" data-toggle="tab" >入库单查询<span id="unfold"></span> </a>
			</li>
		</ul>
		
		   <div class="tab-content">
				<div class="tab-pane ${tab1}" id="tab1">
				   
				   <form id="inputForm" action="${ctx}/instorageBill/create" method="post" class="form-horizontal">
						<fieldset>
							<div style="height: 10px;"></div>
							<div class="container" style="margin-left: -50px;">
							  <!-- 行1 -->
						      <div class="row">
						             <div class="span4">
											<div class="control-group">
												<label  class="control-label">入库类型:</label>
												<div class="controls">
													<select id="billType" name="billType" class="required">
														<option value=""></option>
															<option value="1">总仓入库</option>
															<option value="2">分仓入库</option>
													</select>
												</div>
											</div>
							          </div>
						      
							          <div class="span4">
											<div class="control-group">
												<label  class="control-label">出货分仓:</label>
												<div class="controls">
													<select id="outstorageCode" name="outstorageCode" class="required">
														<option value=""></option>
														<c:forEach items="${areagroupList}" var="areagroup">
															<option value="${areagroup.groupCode}">${areagroup.groupName}</option>
														</c:forEach>
													</select>
												</div>
											</div>
							          </div>
							        
						       </div>
						       
						       
						        <!-- 行2 -->
							   <div class="row" >
							           
							           <div class="span4">
								      	    <div class="control-group">
											  <label  class="control-label" >商户名称:</label>
											  <div class="controls" >
												<select id="customerCode" name="customerCode"  class="required">
														<option value=""></option>
														<c:forEach items="${customersList}" var="customer">
															<option value="${customer.customerCode}">${customer.customerName}</option>
														</c:forEach>
													</select>
											  </div>
											</div>
							      	   </div>
							      
							   			<div class="span4">
									      	    <div class="control-group">
													<label  class="control-label">箱子数量:</label>
													<div class="controls">
													   <input type="text" id="boxNum" name="boxNum"  class="input-large digits" />
													</div>
											   </div>
								         </div>
							      		 
							       </div>   
							 
							  <!-- 行3 -->      
							 <div class="row">
							 
							    <div class="span4">
						      	    <div class="control-group">
										<label  class="control-label">SKU数量:</label>
										<div class="controls">
											 <input type="text" id="skuNum" name="skuNum"  class="input-large digits" />
										</div>
									</div>
						      	 </div>
						      	 
						      	 <div class="span4">
						      	   <div class="control-group">
										<label  class="control-label">商品数量:</label>
										<div class="controls">
										    <input type="text" id="goodsNum" name="goodsNum"  class="input-large digits" />
										</div>
									</div>
						         </div>
							 
							 </div>      
							       
						           
						      <!-- 行3 -->
						      <div class="row" >
						      
								      <div class="span8">
							      	    <div class="control-group">
											<label  class="control-label">备注信息:</label>
											<div class="controls">
												<textarea rows="3" id="remarks" name="remarks" style="width: 537px;" maxlength="100"></textarea>
											</div>
										</div>
						             </div>
							      	
						       </div>
						       
						      <!-- 行3 -->
						      <div class="row" >
						      		 <div class="span8">
							      	   <div class="control-group">
											<label  class="control-label">上传随货单:</label>
											<div class="controls" >
											    <input type="file" id="picPath" name="doc" onchange="previewImage(this);" />
												<div id="preview_div" style="width: 552px; height: 200px; border: ridge; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale); ">
												   <img src="${ctx}/static/images/noexist.jpg" style='width:552px;height:200px; '  />
												</div>
											</div>
										</div>
							      	</div>
							      	
						       </div>
						       
						       
							</div>
							
							<div class="form-actions">
								<input id="submit_btn" class="btn btn-primary" type="submit" value="提交"/>&nbsp;	
								<input id="cancel_btn" class="btn" type="button" value="重置" onclick="formReset();"/>
								<input type="reset" style="display:none;" /> 
							</div>
							
								      
						</fieldset>
					</form>
				   
				   
				</div>
				
				<div class="tab-pane ${tab2}" id="tab2">
					<div style="height: 10px;"></div>
					<table class="table table-striped table-bordered table-condensed">
						<thead>
							<tr>
								<th> 区间范围 </th>
								<th> 折扣类型 </th>
								<th> 付款总额折扣 </th>
								<th> 单票优惠金额(元) </th>
								<th> 有效期 </th>
								<th> 操作人 </th>
								<th> 操作时间 </th>
								<th> 管理</th>
							</tr>
						</thead>
						<tbody >
							<c:forEach items="${discountPriceList}" var="discountPrice">
								<tr >
									<td>${fn:replace(discountPrice.startPrice,'.0','')} — ${fn:replace(discountPrice.endPrice,'.0','')}</td>
									<td> 
									   <c:if test="${discountPrice.discountType eq '1'}">按总金额</c:if>
									    <c:if test="${discountPrice.discountType eq '2'}">按总票数</c:if>
									</td>
									<td> ${discountPrice.discount} </td>
									<td> ${discountPrice.favourablePrice} </td>
									<td> ${fn:substring(discountPrice.beginTime,0,10)} 至 ${fn:substring(discountPrice.endTime,0,10)}  </td>
									<td> ${discountPrice.user.username} </td>
									<td> ${fn:substring(discountPrice.modifyTime,0,19)} </td>
									<td>
									     <a href="#delete_${discountPrice.id}" role="button" class="btn btn-danger" data-toggle="modal">删除</a>
										    <div id="delete_${discountPrice.id}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
												<div class="modal-body">
													<h4>确定删除配置数据吗？</h4>
												</div>
												<div class="modal-footer">
													<button class="btn" data-dismiss="modal" aria-hidden="true">返回</button>
													<a class="btn btn-danger" href="${ctx}/customerDiscountPrice/delete/${discountPrice.id}/settingId/${setting.id}">确定</a>
												</div>
											 </div>
										  <a href="${ctx}/customerDiscountPrice/update/${discountPrice.id}" class="btn btn-info ">修改</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				
	    </div>
	</div>
	
</body>
</html>
